package test;

/**
 * @Description 单例模式
 * @Author Firenut
 * @Date 2023-08-23 00:11
 */
public class SingletonDemo {
    private volatile static SingletonDemo singleton;

    private SingletonDemo() {
    }

    public SingletonDemo getSingleton() {
        if (singleton == null) {
            synchronized (SingletonDemo.class) {
                if (singleton == null) {
                    singleton = new SingletonDemo();
                }
            }
        }
        return singleton;
    }
}
